#!/bin/sh

rel2abs()
{
    # make sure file is specified
    if [ -z "$1" ]
    then
       echo "$0 <path>"
       return 1
    fi

    # already absolute case
    if [ "${1:0:1}" = "/" ] || [ "$PWD" = "/" ]
    then
       ABS=""
    else
       ABS="$PWD"
    fi

    # loop thru path
    IFS="/"
    for DIR in $1
    do
       if [ -n "$DIR" ]
       then
          if [ "$DIR" = ".." ]
          then
             ABS="${ABS%/*}"

          elif [ "$DIR" != "." ]
          then
             ABS="$ABS/$DIR"

          fi
       fi
    done
    IFS=":"

    echo $ABS
    return 0
} 

realpath="`rel2abs $0`"
DIRNAME="`dirname "$realpath"`"

LD_LIBRARY_PATH="$DIRNAME/wine_distrib/lib:$DIRNAME/wine_distrib/lib/wine:$LD_LIBRARY_PATH" WINEPREFIX="$DIRNAME/wine_prefix" $DIRNAME/wine_distrib/bin/wine  "$@"
